fix(memory): make reconcileFacts safe under FORGE_LEDGER_ONLY (M2, partial)#105
Merged
Merged
Conversation
…ge 1) reconcileFacts tombstones any author-owned fact claim that has no backing file in the store. Under ledger-only there are no fact files, so it would tombstone EVERY fact -- silently wiping memory. It is now a guarded no-op when ledger-only is active: the ledger is the store then, so there is nothing to reconcile against. This is the destructive-heuristic fix that has to land BEFORE the default can be flipped. Adds a no-data-loss regression test (two ledger-only facts survive a reconcile). Full suite 1070 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01C7htTiesXKLvAUtv6ET2jz
CodeWithJuber
marked this pull request as ready for review
July 20, 2026 15:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Partial progress on M2 (finish the ledger-only memory migration) — specifically the
one destructive step, done safely and in isolation.
reconcileFacts(src/ledger_bridge.js) tombstones any author-ownedfactclaim thathas no backing file in the store. Under
FORGE_LEDGER_ONLYthere are no fact files, so itwould tombstone every fact — silently wiping the user's memory the first time
forge recall consolidateran. It is now a guarded no-op when ledger-only is active: theledger IS the store then, so there is nothing to reconcile against. A new regression test
asserts two ledger-only facts survive a reconcile (no data loss).
This is the prerequisite the rest of M2 depends on — it makes
FORGE_LEDGER_ONLY=1safeto opt into today.
Scope note — the default flip is intentionally NOT in this PR
Flipping the
FORGE_LEDGER_ONLYdefault to on (and deleting the legacy stores) isdeliberately deferred: piloting the flip surfaced 31 failing tests, and crucially not
all are stale default-off assertions — some expose real ledger-only path gaps that
would need fixing first, e.g.:
brain.rememberpersists via a file but does not dual-write to the ledger, so underledger-only the fact is lost (
brain.buildIndexindexes 1 instead of 2).localLessons, whose sourcechanges under ledger-only — the candidate→active lifecycle needs re-verification.
Those are correctness-critical fixes across the memory subsystem and belong in their own
reviewed change, not rushed alongside a default flip. This PR lands only the safe,
self-contained destructive-heuristic fix.
Checklist
npm testpasses (1070 pass / 0 fail / 2 gated skips — includes the new test)npm run checkpasses (Biome — 0 errors)CHANGELOG.mdupdated under## [Unreleased]Risk & rollback
Extra checks
npm run typecheckpassesnode src/cli.js docs checkgreen🤖 Generated with Claude Code
https://claude.ai/code/session_01C7htTiesXKLvAUtv6ET2jz
Generated by Claude Code